<%--
    Document   : index
    Created on : 12.02.2010, 22:48:51
    Author     : Morfant
--%>

<%@page import="stud.cp.user.valueobjects.Parameter"%>
<%@page import="java.util.Map"%>
<%@page import="java.math.BigInteger"%>
<%@page import="stud.cp.user.valueobjects.DBObject"%>
<%@page import="stud.cp.user.valueobjects.DBObjectType"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"
        language="java"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <%@include file="/header.jsp"%>
    <body>
        <div class="page">
            <%@include file="/cap.jsp"%>
            <div id="main">
                <%@include file="/Designer/designer_cap.jsp" %>
                <%List<DBObject> listOfProduct = (List<DBObject>) request.getAttribute(PluginConst.OBJECT_LIST);
                    Map<BigInteger, Parameter> productAmoutMap = (Map<BigInteger, Parameter>) request.getAttribute(PluginConst.PRODUCT_AMOUNT_MAP);
                    String fromDate = (String) request.getAttribute(PluginConst.DATE_FROM);
                    String toDate = (String) request.getAttribute(PluginConst.DATE_TO);%>
                <h2>Список расхода продуктов.</h2>

                <p>
                    За промежуток с <%=fromDate%> по <%=toDate%>.
                </p>

                <%
                    if ((listOfProduct != null) && (listOfProduct.size() > 0)) {
                %>
                <table>
                    <tr>
                        <th>Продукт</th>
                        <th>Расход</th>
                    </tr>
                    <%
                        for (DBObject item : listOfProduct) {
                    %>
                    <tr>
                        <td>
                            <%=item.getName()%>
                        </td> 
                        <td>
                            <%=(productAmoutMap.get(item.getObject_id()).getValue()
                           + (productAmoutMap.get(item.getObject_id()).getProperty_list_value_id().equals(new BigInteger("3")) ? " кг." : " шт."))%>
                        </td>
                    </tr>
                    <%}%>
                </table>
                <%} else {%>
                Продуктов, удовлетворящих условиям, не найдено.
                <%}%>

                <div id="objectmenucontainer">
                    <ul id="objectmenu">
                        <li><a href="<%= response.encodeURL("query-action.do")
                                + "?"
                                + PluginConst.SUBACTION
                                + "="
                                + PluginConst.GET_CONSUMPTION%>">Вернуться к запросу</a></li>
                    </ul> 
                </div>
            </div>
        </div>
    </body>
</html>
